#include <iostream>
#include "Socket.h"
#include <unistd.h>
#include <sys/socket.h>
#include <errno.h>

using std::cout;
using std::endl;

Socket::Socket()
{
    _fd = socket(AF_INET, SOCK_STREAM, 0);
    if (_fd < 0)
    {
        cout << "error: socket" << endl;
        exit(-1);
    }
}

Socket::Socket(int fd)
    : _fd{fd}
{
}

Socket::~Socket()
{
    close(_fd);
}

int Socket::fd() const
{
    return _fd;
}